package com.viking.authentication.gui;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

import static javax.swing.SpringLayout.*;

public class LoginWindowForgetPassword {

    public LoginWindowForgetPassword()
    {

        JFrame jf = new JFrame("忘记密码");
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        jf.setSize(500, 300);
        JPanel jp = new JPanel();
        jf.setContentPane(jp);
        SpringLayout springLayout = new SpringLayout();
        jp.setLayout(springLayout);

        //显示账号
        JLabel account_text = new JLabel("账号：");
        jp.add(account_text);
        account_text.setForeground(Color.white);
        springLayout.putConstraint(NORTH, account_text, 50, NORTH, jp);  //标签1北侧——>容器北侧
        springLayout.putConstraint(WEST, account_text, 35, WEST, jp);    //标签1西侧——>容器西侧 10

        //文本框组件的位置约束
        JTextField account = new JTextField();
        jp.add(account);
        springLayout.putConstraint(NORTH, account, 50, NORTH, jp);//文本框北侧——>容器北侧
        springLayout.putConstraint(WEST, account, 10, EAST, account_text);//文本框西侧——>主题标签东侧
        springLayout.putConstraint(EAST, account, -50, EAST, jp);// 文本框东侧——>容器东侧



        //标签组件2的位置约束
        JLabel account_text1= new JLabel("员工号: ");
        jp.add(account_text1);
        account_text1.setForeground(Color.white);
        springLayout.putConstraint(NORTH, account_text1, 50, SOUTH, account);// 内容标签北侧(参照文本框是因为文本框高)——>主题文本框南侧
        springLayout.putConstraint(WEST, account_text1, 50, WEST, jp);// 内容标签西侧——>容器西侧

        JTextField account2 = new  JTextField();
        jp.add(account2);
        springLayout.putConstraint(NORTH, account2, 50, SOUTH, account);// 滚动面板北侧——>文本框南侧
        springLayout.putConstraint(WEST, account2, 10, EAST, account_text1);// 滚动面板西侧——>内容标签东侧
        springLayout.putConstraint(EAST, account2, -50, EAST, jp);// 滚动面板东侧——>容器东侧


        JButton Btn_confirm = new JButton("确认");
        jp.add(Btn_confirm);
        springLayout.putConstraint(NORTH, Btn_confirm, 50, NORTH,account2);// 按钮2南侧——>容器南侧
        springLayout.putConstraint(WEST, Btn_confirm, -120, EAST,account2);// 按钮2东侧——>密码框东侧


        jf.setLocationRelativeTo(null);
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        jf.setVisible(true);  // 显示窗口

        JLabel lblBackground = new JLabel(); // 创建一个标签组件对象
        URL resource = this.getClass().getResource("/true.jpg"); // 获取背景图片路径
        ImageIcon icon = new ImageIcon(resource); // 创建背景图片对象
        lblBackground.setIcon(icon); // 设置标签组件要显示的图标
        lblBackground.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); // 设置组件的显示位置及大小
        jp.add(lblBackground);
    }
}
